use alice2d::{ecs::system::{Query, Res}, scene::{TransformComponent, Rigidbody2DComponent, AlicePhysicsWorld}};



pub fn physics_system(
    mut query: Query<(&mut TransformComponent, &Rigidbody2DComponent)>,
    world: Res<AlicePhysicsWorld>,
) {
    for (mut transform, rigidbody) in &mut query {
        let body = &world.rigid_body_set[rigidbody.body_handle];

        let translation = body.translation();
        transform.translation.x = translation.x;
        transform.translation.y = translation.y;
       
        let rotation = body.rotation();

        transform.rotation.z = rotation.angle();

    }
}
